﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Wicture.QPZS.EPC.API.Domain.Entities;

namespace Wicture.QPZS.EPC.API.InvokeContextBuilders.InvokeResultAnalysers
{
    public class QueryVinInvokeResultAnalyser : IInvokeResultAnalyser
    {
        public string ServiceName => "QueryVin";

        public void Analyse(ThrottlingContext context, Wicture.DbRESTFul.ExecutionContext executionContext)
        {
            var data = JToken.FromObject(executionContext.Result);
            var brandCode = data.Value<string>("brandCode");
            if (!string.IsNullOrEmpty(brandCode))
            {
                context.BrandCode = brandCode;
            }
        }
    }
}
